<#include "/common/defaultEngine.html"/>
<@pageTheme mark="${config.optimize()?string('true', 'false')}">
<@header title="附件管理" bodyClass="gray-bg animated fadeInRight" isAnimation=false libs=["table","zTree","layout-latest"]/>
<div class="container-div">
 <div class="row">
  <div class="col-sm-12 search-collapse">
    <@f.tip class="warning" closeTime=5>
      ${i18n("上传组件支持上传下载对象存储OSS、默认本地。目前系统支持阿里OSS")}
    </@f.tip>
    <@f.form id="file-form">
     <div class="select-list">
      <ul>
           <li>
              <label> ${i18n("文件名称")}：
               <input type="text" class="form-control" name="fileName"/> </label>
            </li>
             <li>
              <label> ${i18n("业务类型")}：
               <input type="text" class="form-control" name="fileUpload.bizType"/> </label>
            </li>
          <li>
              <label> ${i18n("状态")}：</label>
              <@f.select name="status" dictType="sys_file_status" blankValue="" blankLabel="所有"/>
          </li>
        <li>
          <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;&nbsp;${i18n("查询")}</a>
          <a class="btn btn-warning btn-rounded btn-sm" onclick="opt.form.reset()"><i class="fa fa-refresh"></i>&nbsp;${i18n("重置")}</a>
       </li>
      </ul>
   </div>
  </@f.form>
 </div>
  <@table id="bootstrap-table">
    <@shiro.hasPermission name="sys:file:del">
        <a class="btn btn-danger multiple disabled" onclick="opt.operate.delAll()">
            <i class="fa fa-remove"></i> ${i18n("删除")}
        </a>
    </@shiro.hasPermission>
   </@table>
  </div>
</div>
<@footer>
<script type="text/javascript">
    var delFlag = "${permission.hasPermi("sys:file:del")}";
    var visible = ${permission.isPermitteds("sys:file:del")?string('true', 'false')};
    var prefix = baseURL + "sys/file";

    $(function() {
        var options = {
            url: prefix + "/list",
            delUrl: prefix + "/del",
            modalName: $.i18n.prop("文件"),
            uniqueId:  'id',/* 唯一ID */
            escape: true,/* 分页设置 */
            showPageGo: true,/* 分页设置 */
            pageSize: 10,/* 分页设置 */
            pageList: [10, 30, 50],/* 分页设置 */
            sortName: "createTime",
            height: function(){ return $(window).height() - 100},
            columns: [
                {title: $.i18n.prop("序号"), width: 5, align: "center", formatter: function (value, row, index) {
                            return $.table.serialNumber(index);
                }}
              ,{field : 'id',title : '${i18n("文件主键ID")}',visible: false}
              ,{field : 'fileName',title : '${i18n("文件名称")}' ,formatter: function(value, row, index) {
                            return opt.common.tooltip(value,10);
                        }}
              ,{field : 'type',title : '${i18n("文件类型")}',formatter: function(value,row, index){
                        return opt.common.getExt(row.fileName);
               }}
             ,{field : 'classify',title : '${i18n("文件归类")}' ,formatter: function(value, row, index) {
                        return opt.common.selectDictLabel("sys_file_classify", value);
                }}
              ,{field : 'fileUpload.bizType',title : '${i18n("业务类型")}'}
              ,{field : 'fileUpload.bizId',title : '${i18n("业务ID")}',visible: false}
              ,{field : 'ossType',title : '${i18n("对象存储OSS类型")}',formatter: function (value, row, index) {
                        return opt.common.selectDictLabel("sys_oss_type", value);
               }}
              ,{field : 'filePath',title : '${i18n("相对路径")}' ,formatter: function(value, row, index) {
                        return opt.common.tooltip(value,20);
                    }}
              ,{field : 'fileSize',title : '${i18n("文件大小")}',formatter: function(value, row, index) {
                        return opt.common.bytesToSize(value);
              }}
              ,{field : 'createBy',title : '${i18n("创建者")}'}
              ,{field : 'createTime',title : '${i18n("创建时间")}',sortable: true}
              ,{field: 'status', title: "${i18n("状态")}", formatter: function (value, row, index) {
                        return opt.common.selectDictLabel("sys_file_status", value);
                    }
                }
                 ,{title:"${i18n("操作")}",align: 'center',visible:visible,formatter: function(value, row, index) {
                        var actions = [];
                         actions.push('<a class="btn btn-default btn-xs preview " href="javascript:void(0)" onclick="opt.modal.openView(\''+row.fileName+'\', \''+baseURL+'sys/comm/fileUploadView?fileId=' + row.id + '\')"><i class="fa fa-eye"></i> ${i18n("预览")}</a> ');
                         actions.push('<a class="btn btn-primary btn-xs " href="javascript:void(0)" onclick="opt.common.downLoadFile(\''+baseURL+'sys/comm/download?fileId=' + row.id + '\')" title="${i18n('下载')}"><i class="fa fa-download"></i> ${i18n("下载")}</a> ');
                         actions.push('<a class="btn btn-danger btn-xs ' + delFlag + '" href="javascript:void(0)" onclick="opt.operate.del(\'' + row.id + '\')"><i class="fa fa-remove"></i> ${i18n("删除")}</a>');
                        return actions.join('');

                    }
                 }
            ]};
            $.table.init(options);
        });

</script>
</@footer>
</@pageTheme>